﻿// JScript File

//function getLikeElements(tagName) 
//{
//    var startSet;
//    if (tagName) 
//    {
//        startSet = document.getElementsByTagName(tagName);    
//    } 
//    else 
//    {
//        startSet = (document.all) ? document.all : document.getElementsByTagName("*");
//    }
//    return startSet;
//}

function getXMLHttpRequest()
{
    var XMLHttpRequestObject = false;
    if (window.XMLHttpRequest) 
    {
        XMLHttpRequestObject = new XMLHttpRequest();
    } 
    else if (window.ActiveXObject) 
    {
        XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return XMLHttpRequestObject
}

function getData(reqURL, objName, divID)
{
    var XMLHttpRequestObject=getXMLHttpRequest()
    if(XMLHttpRequestObject) 
    {
        var objSource = document.getElementById(objName);
        var objDest = document.getElementById(divID);
        var url = reqURL+'?name='+escape(objName)+'&'+escape(objName)+'='+escape(objSource.value);
        XMLHttpRequestObject.open("GET", url);
        XMLHttpRequestObject.onreadystatechange = function()
        {
            if (XMLHttpRequestObject.readyState == 4 &&
            XMLHttpRequestObject.status == 200) 
            {
                objDest.innerHTML = XMLHttpRequestObject.responseText;
            }
        }
        XMLHttpRequestObject.send(null);
    }
}

//function SendRequstFromSelect(selName,reqURL)
//{
//    var obj = document.getElementById(selName);
//    if (obj == null ) 
//    { 
//        return; 
//    }
//    var url = reqURL+'?'+selName+'='+obj.value;
//    location.href=url;
//}

function RefreshFromControl(selName,selPrefix,reqURL)
{
    var objSelect = document.getElementById(selName);
    if (objSelect == null ) 
    { 
        return; 
    }
    var url = reqURL+'?name='+selName+'&'+selName+'='+objSelect.value+'&prefix='+selPrefix;
    var XMLHttpRequestObject=getXMLHttpRequest();
    if(XMLHttpRequestObject) 
    {
        XMLHttpRequestObject.open("GET", url);
        XMLHttpRequestObject.onreadystatechange = function()
        {
            if (XMLHttpRequestObject.readyState == 4 &&
            XMLHttpRequestObject.status == 200) 
            {
                var strResult=XMLHttpRequestObject.responseText;
                if (strResult == null) 
                { 
                    return; 
                }
                    var strResult = XMLHttpRequestObject.responseText;
                    var arrResult = strResult.split(';');
                    var intLimit = arrResult.length/2-1;
                    for (var x = 0; x <= intLimit; x++)
                    {
                        if (document.getElementById(arrResult[x*2]) != null)
                        {
                            document.getElementById(arrResult[x*2]).value = arrResult[x*2+1];
                        }
                        else
                        { 
                            return; 
                        }
                    }                    
            }
        }
        XMLHttpRequestObject.send(null);
    }
}

function test()
{
    alert('test')
}